﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Cstudy.DAL
{
    public class reply
    {
        public bool AddReply(MODEL.reply reply)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@topicid",reply.TopicID),
                new SqlParameter("@content",reply.Content),
                new SqlParameter("@authorid",reply.Authorid)
            };
            return COM.SQLHelper.ExecuteNonQuery("sp_AddReply", parms);
        }

        public bool DeleteReply(int replyid)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@id",replyid)
            };
            return COM.SQLHelper.ExecuteNonQuery("sp_DeleteReply", parms);
        }

        public bool UpdateReply(MODEL.reply reply)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@replyid",reply.ReplyID),
                new SqlParameter("@content",reply.Content)
            };
            return COM.SQLHelper.ExecuteNonQuery("sp_UpdateReply",parms);
        }

        public DataSet SelectReplyByTopicID(int topicid)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@topicid",topicid)
            };
            return COM.SQLHelper.ExecuteQuery("sp_SelectReplyByTopicID", parms);
        }
    }
}
